from django.db import models
# Create your models here.
from django.db.models import CASCADE

#首页展示的主要分类，个性昵称  王者荣耀昵称  跑跑卡丁车昵称 QQ飞车昵称
class WangMing_Type(models.Model):
    typeid = models.AutoField(primary_key=True)

    choice_statues = ((1, '显示'), (0, '隐藏'))
    type_statues = models.IntegerField(default=0, blank=False, choices=choice_statues)

    typename = models.CharField(max_length=10,default='个性昵称', blank=False,null=False)
    typeIMG = models.ImageField(upload_to='scoreimgs/%Y/%m/%d', default=None, blank=True, null=True)
    typeweight = models.IntegerField(default=1, blank=False, null=False)  # 禁止留空(类型权重)
    def __str__(self):
        return f'{self.typename}类型，权重为{self.typeweight}'
    class Meta:
        verbose_name = '网名小程序分类表'
        verbose_name_plural = verbose_name


# 分类下每个项目小清新昵称   个性昵称    翅膀昵称
class WangMing_Score(models.Model):
    fenxiangid = models.AutoField(verbose_name='商品ID',primary_key=True)
    fenxiangname = models.CharField(verbose_name='分享标题',max_length=100,default='分享内容', blank=False,null=False)   #禁止空
    fenxiangIMG = models.ImageField(upload_to='scoreimgs/%Y/%m/%d', default='scoreimgs/bg/default.jpg', blank=True, null=True) #允许空
    score_type = models.ForeignKey('WangMing_Type',related_name='scoretype',default=None,blank=False,on_delete=CASCADE) #blank =false 表单必须填写内容

    word = models.CharField(verbose_name='介绍语句', max_length=200, default='说明标题',blank=True, null=True) #
    word1 = models.CharField(verbose_name='介绍语句', max_length=200, default='第1段内容',blank=True, null=True) #
    word2 = models.CharField(verbose_name='介绍语句', max_length=200, default='第2段内容',blank=True, null=True) #
    word3 = models.CharField(verbose_name='介绍语句', max_length=200, default='',blank=True, null=True) #
    word4 = models.CharField(verbose_name='介绍语句', max_length=200, default='',blank=True, null=True) #
    word5 = models.CharField(verbose_name='介绍语句', max_length=200, default='',blank=True, null=True) #
    word6 = models.CharField(verbose_name='介绍语句', max_length=200, default='',blank=True, null=True) #
    choice_statues = ((1, '上架'), (0, '下架'))
    statues = models.IntegerField(verbose_name='商品状态',default=0,blank=False,choices=choice_statues) #禁止留空

    itemweight = models.IntegerField(verbose_name='展示权重',default=1,blank=False,null=False) #禁止留空(权重)
    clickNum = models.IntegerField(verbose_name='查看人数',default=0,blank=False,null=False)
    templateName = models.CharField(verbose_name='子页面模板名', max_length=200, default='style1',blank=True, null=False) #禁止空  模板的名称，对应到前台的页面名称进行跳转
    templateImgSrc = models.ImageField(upload_to='scoreimgs/%Y/%m/%d', default=None, blank=True, null=True)#禁止空  模板的名称，对应到前台的页面名称进行跳转
    def __str__(self):
        return f'id:[{self.fenxiangid}],{self.score_type.typename}类型的账号：{self.fenxiangname}，权重为：{self.itemweight}'
    class Meta:
        verbose_name = '账号详情表'
        verbose_name_plural = verbose_name
        ordering = ['itemweight','fenxiangid']


# 分类下子类 的孙子类（存储符号），这个还是一对多，这个是多
class WangMing_Chars(models.Model):
    charsid = models.AutoField(verbose_name='符号ID',primary_key=True)
    charName = models.CharField(verbose_name='名称',max_length=100,default='字符名称', blank=False,null=False)   #禁止空
    char_Score = models.ForeignKey('WangMing_Score',related_name='charscore',default=None,blank=False,on_delete=CASCADE) #blank =false 表单必须填写内容
    choice_type = (('1', '循环模式1'), ('2', '遍历模式2'))
    type = models.CharField(verbose_name='模式选择',max_length=2,default=1,blank=False,choices=choice_type) #禁止留空
    char1 = models.CharField(verbose_name='符号1',max_length=100,default='', blank=True,null=True)   #允许空
    char2 = models.CharField(verbose_name='符号1',max_length=100,default='', blank=True,null=True)   #允许空
    char3 = models.CharField(verbose_name='符号1',max_length=100,default='', blank=True,null=True)   #允许空
    char4 = models.CharField(verbose_name='符号1',max_length=100,default='', blank=True,null=True)   #允许空
    itemweight = models.IntegerField(verbose_name='展示权重',default=1,blank=False,null=False) #禁止留空(权重)
    def __str__(self):
        return f'id:[{self.charsid}],{self.char_Score.fenxiangname}类型的账号：{self.charName}，权重为：{self.itemweight}'
    class Meta:
        verbose_name = '符号详情表'
        verbose_name_plural = verbose_name
        ordering = ['-itemweight','-charsid']